{
  let rec count_occ s e = 
    let rec aux s n size c e = 
      if c = size then n
      else aux s (if s.[c] = e then n+1 else n) size (c+1) e
    in aux s 0 (String.length s) 0 e

  let output = ref "" and com = ref ""
  let add s = output := !output^s
  let add_com s = com := !com^s
  let trait_coms () = add (String.make (count_occ !com '\n') '\n'); com := ""
}

rule normal = parse 
  | "/*"  { ignore (Lexing.lexeme lexbuf); commentaire lexbuf; normal lexbuf }
  | '"'   { add (Lexing.lexeme lexbuf); chaine lexbuf; normal lexbuf }
  | _     { add (Lexing.lexeme lexbuf); (normal lexbuf) }
  | eof   { () }

and commentaire = parse 
  | "*/"    { trait_coms (); ignore (Lexing.lexeme lexbuf) }
  | _       { add_com (Lexing.lexeme lexbuf); commentaire lexbuf  }
  | eof     { () }

and  chaine = parse 
    '"'     { add (Lexing.lexeme lexbuf) }
  | "\\\""  { add (Lexing.lexeme lexbuf); chaine lexbuf }
  | _       { add (Lexing.lexeme lexbuf); chaine lexbuf }


{

let decommente s = 
  let lb = Lexing.from_string s in
    normal lb; let e = !output in  output := ""; com := ""; e

}
